/*
 * @Author: zhang zhijiang 2824735304@qq.com
 * @Date: 2025-03-21 16:57:05
 * @LastEditors: zhang zhijiang 2824735304@qq.com
 * @LastEditTime: 2025-03-21 17:13:39
 * @FilePath: /linux/test_3_21/lock.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once
#include<pthread.h>
#include<iostream>
using namespace std;
class mutex
{
    public:
    mutex(pthread_mutex_t * lock)
    :_lock(lock)
    {}
    void lock()
    {
        pthread_mutex_lock(_lock);
    }
    void unlock()
    {
        pthread_mutex_unlock(_lock);
    }
    ~mutex()
    {}
    public:
    pthread_mutex_t* _lock;
};
class mylock
{
    public:
    mylock(mutex lock)
    :_mutex(lock)
    {
        _mutex.lock();
    }
    ~mylock()
    {
        _mutex.unlock();
    }
    public:
    mutex _mutex;
};

